#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int n;
    string str;
    cin >> str >> n;

    int left = 0;
    int right = 0;
    int count = 0;
    int countMax = 0;
    int begin = -1;
    while (right < str.size())
    {
        if (str[right] == 'C' || str[right] == 'G')
            count++;
        if (right - left >= n)
        {
            if (str[left] == 'C' || str[left] == 'G')
                count--;
            left++;
        }
        if (count > countMax)
        {
            countMax = count;
            begin = left;
        }
        right++;
    }

    cout << str.substr(begin, n) << endl;

    return 0;
}